netsuite-js

Service

declaration
Service ->Service

Option name Type Description
config NetSuite.Configuration

A service client through which requests are sent.

var Service = module.exports = function Service(config) {
  this.config = config;
};

init

method
Service.prototype.init() ->Promise.<client>

Option name Type Description
[skipDiscovery=false] Boolean Don't try to discover WSDL url

Initialize this service client with given config.

Service.prototype.init = function(skipDiscovery) {
  return this.config.createConnection(skipDiscovery);
};

get

method
Service.prototype.get() ->Promise.<result rawResponse soapHeader>

Option name Type Description
recordRef NetSuite.Records.RecordRef

result description:

result.readResponse.status {String} Operation status. Contains more details on errors.
result.readResponse.status.$attributes.isSuccess {String} Whether op was successful. String values of 'true' or 'false'
[result.readResponse.status.statusDetail] {StatusDetail[]} Status details on error.
result.readResponse.record {Record} The actual record. Its type is dependent on the given recordRef.type

Service.prototype.get = function(recordRef) {
  assertConnection(this);

  var soapObj = Serializer.serialize(recordRef);
  var get = denodeify(this.config.client.get);
  return get(soapObj);
};

getAll

method
Service.prototype.getAll() ->Promise.<result rawResponse soapHeader>

Option name Type Description
recordType String from `GetAllRecordType` enumeration in `coreTypes.xsd`

Note that not all record types work with the getAll operation. Supported types
are listed in the GetAllRecordType enumeration in coreTypes.xsd.

result description:

result.getAllResult.status {String} Operation status. Contains more details on errors.
result.getAllResult.status.$attributes.isSuccess {String} Whether op was successful. String values of 'true' or 'false'
[result.getAllResult.status.statusDetail] {StatusDetail[]} Status details on error.
result.getAllResult.recordList {Record[]} The actual records. Their types are dependent on the given recordRef.types
result.getAllResult.totalRecords {Number}

Service.prototype.getAll = function(recordType) {
  assertConnection(this);

  var param = {
    record: {
      recordType: recordType
    }
  };
  var getAll = denodeify(this.config.client.getAll);
  return getAll(param);
};

getList

method
Service.prototype.getList() ->Promise.<result rawResponse soapHeader>

Option name Type Description
recordRefs NetSuite.Records.RecordRef[] array of RecordRefs

result description:

result.readResponseList.status {String} Operation status. Contains more details on errors.
result.readResponseList.status.$attributes.isSuccess {String} Whether op was successful. String values of 'true' or 'false'
[result.readResponseList.status.statusDetail] {StatusDetail[]} Status details on error.
result.readResponseList.readResponse {Record[]} The actual records. Their types are dependent on the given recordRef.types

Service.prototype.getList = function(recordRefs) {
  assertConnection(this);

  var soapObj = Serializer.serialize(recordRefs);
  var getList = denodeify(this.config.client.getList);
  return getList(soapObj);
};
Option name Type Description
searchRecord NetSuite.Search.EmployeeSearchBasic,Object

result description:

result.searchResult.status {String} Operation status. Contains more details on errors.
result.searchResult.status.$attributes.isSuccess {String} Whether op was successful. String values of 'true' or 'false'
[result.searchResult.status.statusDetail] {StatusDetail[]} Status details on error.
result.searchResult.pageIndex {Number} one based
result.searchResult.pageSize {Number}
result.searchResult.recordList.record {Record[]} The actual records. Their types are dependent on the search type
result.searchResult.searchId {String}
result.searchResult.totalPages {Number}
result.searchResult.totalRecords {Number}

Service.prototype.search = function(searchRecord) {
  assertConnection(this);

  var soapObj = Serializer.serialize(searchRecord);
  var search = denodeify(this.config.client.search);
  return search(soapObj);
};

searchMoreWithId

method
Service.prototype.searchMoreWithId() ->Promise.<result rawResponse soapHeader>

Option name Type Description
searchId String search id from original search
pageIndex Number target page index to retrieve

result description:

result.searchResult.status {String} Operation status. Contains more details on errors.
result.searchResult.status.$attributes.isSuccess {String} Whether op was successful. String values of 'true' or 'false'
[result.searchResult.status.statusDetail] {StatusDetail[]} Status details on error.
result.searchResult.pageIndex {Number} one based
result.searchResult.pageSize {Number}
result.searchResult.recordList.record {Record[]} The actual records. Their types are dependent on the search type
result.searchResult.searchId {String}
result.searchResult.totalPages {Number}
result.searchResult.totalRecords {Number}

Service.prototype.searchMoreWithId = function(searchId, pageIndex) {
  assertConnection(this);

  var searchMoreWithId = denodeify(this.config.client.searchMoreWithId);
  return searchMoreWithId({
    searchId: searchId,
    pageIndex: pageIndex
  });
};

setSearchPreferences

method
Service.prototype.setSearchPreferences()

Option name Type Description
preferences NetSuite.Search.SearchPreferences

Adds or updates necessary SOAP headers to set search preferences.
Note these preferences persist across searches until updated or cleared.

Service.prototype.setSearchPreferences = function(preferences) {
  this.config.removeSoapHeader('searchPreferences');
  this.config.addSoapHeader(preferences);
};

clearSearchPreferences

method
Service.prototype.clearSearchPreferences()

Clears search preferences until setSearchPreferences() is called again.

Service.prototype.clearSearchPreferences = function() {
  this.config.removeSoapHeader('searchPreferences');
};